<?php
	require_once("../includes/user.php");
	$user=new User();
?>
<link href="../css/default.css" rel="stylesheet" type="text/css" />

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div class="Innerheading">Dynamic Report Generation</div></td>
  </tr>
  <tr>
    <td><div class="InnerDarkbox">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="right" valign="middle">Report for :</td>
          <td align="left" valign="middle"><select name="type" class="FormTextFeild" id="type">
            <option value="1" selected="selected">Individual</option>
            <option value="2">Housewise</option>
            <option value="3">High Scorer</option>
          </select>          </td>
        </tr>
        <tr style="display:none" id="ho_row">
          <td align="right" valign="middle">Select House :</td>
          <td align="left" valign="middle"><select name="house2" class="FormTextFeild" id="house2">
              <?php 
$house_res=$user->query("select * from house_details where visibility=1 ORDER BY `house_details`.`house_name` ASC");
while($house_row=mysql_fetch_array($house_res))
{
?>
              <option value="<?php echo $house_row['house_id']; ?>"><?php echo $house_row['house_name']; ?></option>
              <?php 
}
?>
          </select></td>
        </tr>
        <tr id="yr_row">
          <td align="right" valign="middle">Select Year :</td>
          <td align="left" valign="middle"><select name="year" class="FormTextFeild" id="year">
             <?php 
			$year_res=$user->query("select * from year_details where visibility=1");
			while($year_row=mysql_fetch_array($year_res))
				{
?>
            <option value="<?php echo $year_row['year_id']; ?>"><?php echo $year_row['year_name']; ?></option>
            <?php 
}
?>
                    </select></td>
        </tr>
        <tr id="st_row">
          <td align="right" valign="middle">Select Student :</td>
          <td align="left" valign="middle"><select name="student" class="FormTextFeild" id="student">
          <?php 
		  	$profile_res=$user->query('select name,id from user_profile where accept=1 AND role =1 AND year=2');
			while($profile_row=mysql_fetch_array($profile_res))
			{
				?>
                <option value="<?php echo $profile_row['id']; ?>"><?php echo $profile_row['name']; ?></option>
                <?php
			}
		  ?>
                    </select></td>
        </tr>
        <tr>
          <td width="43%" align="right" valign="middle">Report duration :</td>
          <td width="57%" align="left" valign="middle"><select name="duration" class="FormTextFeild" id="duration">
              <option value="1">Upto now</option>
              <option value="2">Select duration</option>
                                                                                  </select>          </td>
        </tr>
        <tr id="from_r" style="display:none">
          <td align="right" valign="middle">From :</td>
          <td align="left" valign="middle"><input name="start_date" type="text" class="FormTextFeild" id="start_date" onFocus="popcal('st_dt_cal','start_date')" /> <div id ="st_dt_cal"  style="position:absolute; z-index:1000" ></div> </td>
        </tr>
        <tr id="to_r" style="display:none">
          <td align="right" valign="middle">To :</td>
          <td align="left" valign="middle"><input name="end_date" type="text" class="FormTextFeild" id="end_date" onFocus="popcal('en_dt_cal','end_date')"  /> <div id ="en_dt_cal"  style="position:absolute; z-index:100" ></div></td>
        </tr>
        <tr>
          <td align="right" valign="middle">&nbsp;</td>
          <td align="left" valign="middle"></td>
        </tr>
        <tr>
          <td align="right" valign="middle">&nbsp;</td>
          <td align="left" valign="middle"><input type="image" name="imageField" id="imageField" src="img/buttons/submit.gif" /></td>
        </tr>
      </table>
    </div></td>
  </tr>
</table>
<script>
	$('#duration').change(function(){
		if($('#duration').val()==1){
			$('#from_r').hide();
			$('#to_r').hide();
		}
		else if($('#duration').val()==2){
			$('#from_r').show();
			$('#to_r').show();
		}
	});
	$('#year').change(function(){
		$.post('report/getyearreport.php',{yearid:$('#year').val()},function(data){$('#student').html(data);})
	});
	$('#type').change(function(){
		if($('#type').val()==1){
			$('#yr_row').show();
			$('#ho_row').hide();
			$('#st_row').show();
		}
		else if($('#type').val()==2){
			$('#ho_row').show();
			$('#yr_row').hide();
			$('#st_row').hide();
		}
		else if($('#type').val()==3){
			$('#ho_row').hide();
			$('#yr_row').hide();
			$('#st_row').hide();
		}
	});
</script>